<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>python| socket聊天室 | 一只咸鱼 | 努力学习最新姿势！！！</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="Python">
    <meta name="description" content="服务端1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import socketimport timeimport tkinterfr">
<meta property="og:type" content="article">
<meta property="og:title" content="python| socket聊天室">
<meta property="og:url" content="http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/index.html">
<meta property="og:site_name" content="一只咸鱼">
<meta property="og:description" content="服务端1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import socketimport timeimport tkinterfr">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190104115559751.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70">
<meta property="article:published_time" content="2020-04-06T07:55:00.000Z">
<meta property="article:modified_time" content="2020-04-06T08:36:49.769Z">
<meta property="article:author" content="Mr.Zhang">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20190104115559751.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70">
    
        <link rel="alternate" type="application/atom+xml" title="一只咸鱼" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">Mr.Zhang</h5>
          <a href="mailto:zhangticcc@163.com" title="zhangticcc@163.com" class="mail">zhangticcc@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                首页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                时间轴
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://weibo.com/u/5392412243" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                微博
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/zhangti0708" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                开源地址
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://blog.csdn.net/weixin_40902527" target="_blank" >
                <i class="icon icon-lg icon-rss"></i>
                技术博客
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://zhangticcc.gitee.io/webgis/" target="_blank" >
                <i class="icon icon-lg icon-globe"></i>
                GIS案例
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://mp.weixin.qq.com/s/p4TOhKcr4RZkZWzuMYyBEQ" target="_blank" >
                <i class="icon icon-lg icon-weixin"></i>
                微信订阅号
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">python| socket聊天室</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">python| socket聊天室</h1>
        <h5 class="subtitle">
            
                <time datetime="2020-04-06T07:55:00.000Z" itemprop="datePublished" class="page-time">
  2020-04-06
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/%E5%8D%8F%E8%AE%AE/">协议</a></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#服务端"><span class="post-toc-number">1.</span> <span class="post-toc-text">服务端</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#客户端代码"><span class="post-toc-number">2.</span> <span class="post-toc-text">客户端代码</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#效果"><span class="post-toc-number">3.</span> <span class="post-toc-text">效果</span></a></li></ol>
        </nav>
    </aside>


<article id="post-python-聊天室"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">python| socket聊天室</h1>
        <div class="post-meta">
            <time class="post-time" title="2020-04-06 15:55:00" datetime="2020-04-06T07:55:00.000Z"  itemprop="datePublished">2020-04-06</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/%E5%8D%8F%E8%AE%AE/">协议</a></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h3 id="服务端"><a href="#服务端" class="headerlink" title="服务端"></a>服务端</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br></pre></td><td class="code"><pre><span class="line">import socket</span><br><span class="line">import time</span><br><span class="line">import tkinter</span><br><span class="line">from tkinter.scrolledtext import ScrolledText</span><br><span class="line">import threading</span><br><span class="line">import requests</span><br><span class="line">import tkinter</span><br><span class="line">from socket import *</span><br><span class="line">from time import ctime</span><br><span class="line">from tkinter import *</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">global Text_Show  # 调用人工智能对话的函数，返回人工智能回答</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">def AI_Talk(s):</span><br><span class="line">    print(s)</span><br><span class="line">    response &#x3D; requests.post(&quot;http:&#x2F;&#x2F;www.tuling123.com&#x2F;openapi&#x2F;api&quot;, data&#x3D;&#123;</span><br><span class="line">        &quot;key&quot;: &quot;4105cb6db8c54f5db470b6c0ee42d24b&quot;,</span><br><span class="line">        &quot;info&quot;: s&#125;)</span><br><span class="line">    response &#x3D; response.json()</span><br><span class="line">    answer &#x3D; response[&#39;text&#39;]</span><br><span class="line">    return answer</span><br><span class="line">    # 线程二函数，用来进行对话</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">def Sever_Thread(sock, caddr):</span><br><span class="line">    Text_Show.insert(&#39;end&#39;, &quot;客户端@&quot; + str(caddr[1]) + &quot;已连接!\n&quot;)</span><br><span class="line">    while True:</span><br><span class="line">        # 接收数据</span><br><span class="line">        data &#x3D; str(sock.recv(1024).decode(&#39;UTF-8&#39;))</span><br><span class="line">        if data &#x3D;&#x3D; &quot;quit&quot;:</span><br><span class="line">            Text_Show.insert(&#39;end&#39;, &quot;客户端@&quot; + str(caddr[1]) + &quot;终止了对话\n&quot;)</span><br><span class="line">            Text_Show.see(tkinter.END)</span><br><span class="line">            break</span><br><span class="line">        else:</span><br><span class="line">            Text_Show.insert(&#39;end&#39;, &quot;来自客户端@&quot; + str(caddr[1]) + &quot;的消息为：&quot; + data + &#39;\n&#39;)</span><br><span class="line">            Text_Show.see(tkinter.END)</span><br><span class="line">            # 发送数据</span><br><span class="line">        time.sleep(0.2)</span><br><span class="line">        data &#x3D; AI_Talk(data)  #</span><br><span class="line">        # data &#x3D; &#39;请输入发送至客户端的数据: 123123&#39; #如果要手动输入的话就要设置好线程sleep时间不然还没有输入，就已经到其他线程了，就会发不出去。</span><br><span class="line">        sock.sendall(bytes(data, &#39;UTF-8&#39;))</span><br><span class="line">    sock.close()  # 线程一函数，监听端口，一旦有客户端接入，开启线程二</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">def Sever_Accept(ss):</span><br><span class="line">    while True:</span><br><span class="line">        sock, caddr &#x3D; ss.accept()</span><br><span class="line">        Thread2 &#x3D; threading.Thread(target&#x3D;Sever_Thread, args&#x3D;(sock, caddr))</span><br><span class="line">        Thread2.daemon &#x3D; True  # 线程守护</span><br><span class="line">        Thread2.start()</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"># 服务器初始化</span><br><span class="line">def Sever_Init():</span><br><span class="line">    HOST &#x3D; &#39;&#39;</span><br><span class="line">    PORT &#x3D; 4700</span><br><span class="line">    ADDR &#x3D; (HOST, PORT)</span><br><span class="line">    ss &#x3D; socket(AF_INET, SOCK_STREAM, 0)</span><br><span class="line">    ss.bind(ADDR)</span><br><span class="line">    ss.listen(20)  # 允许最大监听数</span><br><span class="line">    Thread1 &#x3D; threading.Thread(target&#x3D;Sever_Accept, args&#x3D;(ss,))</span><br><span class="line">    Thread1.daemon &#x3D; True  # 线程守护</span><br><span class="line">    Thread1.start()</span><br><span class="line"> </span><br><span class="line">    # 主函数</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">if __name__ &#x3D;&#x3D; &quot;__main__&quot;:</span><br><span class="line">    root &#x3D; tkinter.Tk()</span><br><span class="line">    root.title(&quot;聊天小程序服务器端 &quot;)</span><br><span class="line">    frame1 &#x3D; Frame(root)</span><br><span class="line">    frame1.pack()</span><br><span class="line">    IP_Show_Label &#x3D; Label(frame1, text&#x3D;&quot;默认IP:127.0.0.1\n默认端口为6000\n无法更改!!!&quot;)</span><br><span class="line">    IP_Show_Label.pack(side&#x3D;&#39;left&#39;)</span><br><span class="line">    frame2 &#x3D; Frame(root)</span><br><span class="line">    frame2.pack()</span><br><span class="line">    Text_Show &#x3D; ScrolledText(frame2, width&#x3D;100, height&#x3D;30)</span><br><span class="line">    Text_Show.bind(&quot;&lt;KeyPress&gt;&quot;, lambda e: &quot;break&quot;)</span><br><span class="line">    Text_Show.pack(side&#x3D;&quot;bottom&quot;, fill&#x3D;&#39;both&#39;, expand&#x3D;True)</span><br><span class="line">    Sever_Init()</span><br><span class="line">    root.mainloop()</span><br></pre></td></tr></table></figure>

<h3 id="客户端代码"><a href="#客户端代码" class="headerlink" title="客户端代码"></a>客户端代码</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line">import socket</span><br><span class="line">import time</span><br><span class="line">import tkinter</span><br><span class="line">from tkinter.scrolledtext import ScrolledText</span><br><span class="line">import threading</span><br><span class="line">import requests</span><br><span class="line">import tkinter</span><br><span class="line">from socket import *</span><br><span class="line">from time import ctime</span><br><span class="line">from tkinter import *</span><br><span class="line"> </span><br><span class="line">global cs, Text_Show, Send_Show</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"># 发送按键的函数</span><br><span class="line">def Click_Send():</span><br><span class="line">    sendData &#x3D; Send_Show.get()  # 获取输入内容</span><br><span class="line">    if sendData &#x3D;&#x3D; &#39;quit&#39;:</span><br><span class="line">        Text_Show.insert(tkinter.END, &quot;与服务器连接已断开&quot; + &quot;\n&quot;)</span><br><span class="line">        Text_Show.see(tkinter.END)</span><br><span class="line">        cs.sendall(bytes(sendData, encoding&#x3D;&quot;utf8&quot;))</span><br><span class="line">        cs.close()</span><br><span class="line">    else:</span><br><span class="line">        Text_Show.insert(tkinter.END, &quot;客户端:&quot; + sendData + &quot;\n&quot;)</span><br><span class="line">        Text_Show.see(tkinter.END)</span><br><span class="line">        cs.sendall(bytes(sendData, encoding&#x3D;&quot;utf8&quot;))</span><br><span class="line">    Send_Show.delete(0, END)</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"># 线程函数，循环接受客户端消息</span><br><span class="line">def Receive_Data():</span><br><span class="line">    while True:</span><br><span class="line">        accept_data &#x3D; str(cs.recv(1024), encoding&#x3D;&quot;utf8&quot;)</span><br><span class="line">        Text_Show.insert(tkinter.END, &quot;服务器:&quot; + accept_data + &quot;\n&quot;)</span><br><span class="line">        Text_Show.see(tkinter.END)</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"># 主函数</span><br><span class="line">if __name__ &#x3D;&#x3D; &quot;__main__&quot;:</span><br><span class="line">    # 初始化GUI</span><br><span class="line">    root &#x3D; tkinter.Tk()</span><br><span class="line">    root.title(&quot;聊天小程序客户端 &quot;)</span><br><span class="line">    # 顶部显示部分</span><br><span class="line">    frame1 &#x3D; Frame(root)</span><br><span class="line">    frame1.pack()</span><br><span class="line">    IP_Show_Label &#x3D; Label(frame1, text&#x3D;&quot;本程序默认IP:127.0.0.1\n默认端口为6000\n无法更改!!!&quot;)</span><br><span class="line">    IP_Show_Label.pack(side&#x3D;&#39;left&#39;)</span><br><span class="line">    # 中部聊天框显示部分</span><br><span class="line">    frame2 &#x3D; Frame(root)</span><br><span class="line">    frame2.pack()</span><br><span class="line">    Text_Show &#x3D; ScrolledText(frame2, width&#x3D;70, height&#x3D;15)</span><br><span class="line">    Text_Show.bind(&quot;&lt;KeyPress&gt;&quot;, lambda e: &quot;break&quot;)</span><br><span class="line">    Text_Show.pack(side&#x3D;&quot;bottom&quot;, fill&#x3D;&#39;both&#39;, expand&#x3D;True)</span><br><span class="line">    # 底部消息发送部分</span><br><span class="line">    frame3 &#x3D; Frame(root)</span><br><span class="line">    frame3.pack()</span><br><span class="line">    e3 &#x3D; StringVar()</span><br><span class="line">    Send_Show &#x3D; Entry(frame3, textvariable&#x3D;e3, width&#x3D;60)</span><br><span class="line">    buttontext2 &#x3D; tkinter.StringVar()</span><br><span class="line">    buttontext2.set(&#39;发送&#39;)</span><br><span class="line">    button_Send &#x3D; tkinter.Button(frame3, width&#x3D;10, textvariable&#x3D;buttontext2, command&#x3D;Click_Send)</span><br><span class="line">    Send_Show.pack(side&#x3D;&quot;left&quot;)</span><br><span class="line">    button_Send.pack(side&#x3D;&quot;left&quot;)</span><br><span class="line">    frame3.pack()</span><br><span class="line"> </span><br><span class="line">    # 初始化TCP协议</span><br><span class="line">    HOST &#x3D; &#39;127.0.0.1&#39;</span><br><span class="line">    PORT &#x3D; 4700</span><br><span class="line">    BUFSIZ &#x3D; 1024</span><br><span class="line">    ADDR &#x3D; (HOST, PORT)</span><br><span class="line">    cs &#x3D; socket(AF_INET, SOCK_STREAM, 0)</span><br><span class="line">    cs.connect(ADDR)</span><br><span class="line"> </span><br><span class="line">    thread &#x3D; threading.Thread(target&#x3D;Receive_Data)</span><br><span class="line">    thread.start()</span><br><span class="line"> </span><br><span class="line">    root.mainloop()</span><br></pre></td></tr></table></figure>

<h3 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h3><img alt="" class="has" height="490" src="https://img-blog.csdnimg.cn/20190104115559751.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MDkwMjUyNw==,size_16,color_FFFFFF,t_70" width="737">

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2020-04-06T08:36:49.769Z" itemprop="dateUpdated">2020-04-06 16:36:49</time>
</span><br>


        
        这里可以写作者留言，标签和 hexo 中所有变量及辅助函数等均可调用，示例：<a href="/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" target="_blank" rel="external">http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/</a>
        
    </div>
    
    <footer>
        <a href="http://yoursite.com">
            <img src="/img/avatar.jpg" alt="Mr.Zhang">
            Mr.Zhang
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Python/" rel="tag">Python</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&title=《python| socket聊天室》 — 一只咸鱼&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&title=《python| socket聊天室》 — 一只咸鱼&source=分享各种福利和姿势..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《python| socket聊天室》 — 一只咸鱼&url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2020/04/06/Postgresql-%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B%E8%84%9A%E6%9C%AC/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Postgresql|存储过程脚本</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2020/04/06/%E7%88%AC%E8%99%AB-%E5%9F%BA%E4%BA%8Eredis%E6%90%AD%E5%BB%BAIP%E4%BB%A3%E7%90%86%E6%B1%A0/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">爬虫|基于redis搭建IP代理池</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢大爷~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/img/wechat.jpg" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>Mr.Zhang &copy; 2015 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&title=《python| socket聊天室》 — 一只咸鱼&pic=http://yoursite.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&title=《python| socket聊天室》 — 一只咸鱼&source=分享各种福利和姿势..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《python| socket聊天室》 — 一只咸鱼&url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://yoursite.com/2020/04/06/python-%E8%81%8A%E5%A4%A9%E5%AE%A4/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
